<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="shortcut icon" href="./favicon.ico" />
    <title>我的</title>
    <link rel="stylesheet" href="./font/iconfont.css">
    <link rel="stylesheet" href="./css/my.css">
    <!-- <script src="./js/my.js"></script> -->
</head>

<body>
    <div class="top">我的</div>
    <div class="user">
        <span></span>
        <div>
            <h4 class="yonghu">未登录</h4>
            <!-- <p>手机号12345</p> -->
        </div>
    </div>
    <div class="options">
        <ul>
            <li>
                <span>图标</span>
                <span>订单列表</span>
                <span class="iconfont icon-youjiantou"></span>
            </li>
            <li>
                <span>图标</span>
                <span>优惠券列表</span>
                <span class="iconfont icon-youjiantou"></span>
            </li>
            <li>
                <span>图标</span>
                <span>充值卡</span>
                <span class="iconfont icon-youjiantou"></span>
            </li>
            <li>
                <span>图标</span>
                <span>投诉与建议</span>
                <span class="iconfont icon-youjiantou"></span>
            </li>
        </ul>
    </div>
    <div class="logout">登录</div>
    <div class="footer">
        <div data-url="./index.html">
            <i class="iconfont icon-caidan"></i>
            <span>点单</span>
        </div>
        <div data-url="./my.html">
            <i style="color: #0ff;" class="iconfont icon-wode"></i>
            <span>我的</span>
        </div>
    </div>
</body>
<script>
    window.onload = function () {
        // 底部导航
        var footerNav = document.querySelectorAll('.footer>div')
        for (var a = 0; a < footerNav.length; a++) {
            footerNav[a].onclick = function () {
                location.href = this.dataset.url
            }
        }
    }
    var logout = document.querySelector('.logout')
    var yonghu = document.querySelector('.yonghu')
    // let userid=localStorage.getItem('userid')
    let username = localStorage.getItem('username')
    if (username) {
        logout.innerText = '退出'
        yonghu.innerHTML = username

    }
    logout.onclick = function () {
        // 删除数据
        // localStorage.removeItem('userid')
        // localStorage.removeItem('username')
        // 退出时清除所有缓存
        localStorage.clear()
        location.href = './login.html'
    }

</script>

</html>